home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-03-08 | 6.3 KB | 212 lines | [TEXT/MPS ] |
-
- // ---- End Project Data ----
-
-
- // ---- File ScrollPict.t ----
- ScrollingSample :=
- {title: "Scrolling Sample",
- viewBounds: {left: 0, top: 0, right: 240, bottom: 336},
- _proto: protoApp,
- debug: "ScrollingSample"
- };
-
- clipper1 := /* child of ScrollingSample */
- {viewFlags: 545,
- viewFormat: 337,
- viewBounds: {left: 11, top: 27, right: 231, bottom: 157},
- viewOriginX: 0,
- viewOriginY: 0,
- ScrollMe:
- // This is the function that actually scrolls by using SetOrigin
- // within the clipper1 window. Any child views of the clipper1
- // window will scroll. (That's why the scroller controll isn't
- // a child of the clipper1 window!)
-
- func(deltaX, deltaY)
- begin
- local x := viewOriginX + deltaX;
- local y := viewOriginY + deltaY;
-
- if x > xMax then x := xMax;
- if y > yMax then y := yMax;
-
- if x < 0 then x := 0;
- if y < 0 then y := 0;
-
- :SetOrigin(x, y); // also Dirties the view.
- RefreshViews();
- end,
- xMax: nil,
- yMax: nil,
- viewSetupDoneScript:
- func()
- begin
- xMax := viewWithPict1:LocalBox().right - clipper1:LocalBox().right;
- yMax := viewWithPict1:LocalBox().bottom - clipper1:LocalBox().bottom;
- end,
- viewClickScript:
- func(unit)
- begin
- local startX := GetPoint(firstX, unit);
- local startY := GetPoint(firstY, unit);
- local deltaX;
- local deltaY;
-
- InkOff(unit);
- PlaySound(ROM_click);
- repeat
- deltaX := startX - GetPoint(finalX, unit);
- startX := GetPoint(finalX, unit);
- deltaY := startY - GetPoint(finalY, unit);
- startY := GetPoint(finalY, unit);
- :ScrollMe(deltaX, deltaY);
- until StrokeDone(unit);
- TRUE;
- end,
- viewclass: 74,
- debug: "clipper1"
- };
- // View clipper1 is declared to ScrollingSample
-
- viewWithPict1 := /* child of clipper1 */
- {viewFlags: 1,
- icon: GetPictAsBits("Black World Map", nil),
- viewFormat: 256,
- viewBounds: {top: 0, left: 0, right: 360, bottom: 180},
- viewclass: 76,
- debug: "viewWithPict1"
- };
- // View viewWithPict1 is declared to ScrollingSample
-
-
-
-
-
- scrollCompass := /* child of ScrollingSample */
- {viewFlags: 513,
- viewFormat: 0,
- viewBounds: {left: 12, top: 124, right: 44, bottom: 156},
- viewClickScript:
- // This function is called when the pen is down in the
- // scroller controll, and it calls clipper1:ScrollMe to
- // move the window around. Ideally this view should have
- // its mask set, and if fact the mask is in the resource
- // file, but NTK isn't dealing with the mask properly yet.
-
- func(unit)
- begin
- local deltaX, deltaY;
-
- InkOff(unit);
- PlaySound(ROM_click);
-
- repeat
- // compute where in the view the pen is currently and scroll in the right
- // direction. The values 12 and 20 are pretty arbitrary.
- deltaX := if GetPoint(finalX, unit) < viewBounds.left + 12 then -16
- else if GetPoint(finalX, unit) > viewBounds.left + 20 then 16
- else 0;
-
- deltaY := if GetPoint(finalY, unit) < viewBounds.top + 12 then -16
- else if GetPoint(finalY, unit) > viewBounds.top + 20 then 16
- else 0;
- clipper1:ScrollMe(deltaX, deltaY);
- until StrokeDone(unit);
-
- TRUE;
- end,
- icon: GetPictAsBits("Scroll2D", 1),
- viewclass: 76,
- debug: "scrollCompass"
- };
-
- // After Script for "scrollCompass"
- thisView := scrollCompass;
- thisView.viewTransferMode := modeMask;
-
-
-
- clipper2 := /* child of ScrollingSample */
- {viewFlags: 33,
- viewFormat: 337,
- viewBounds: {top: 170, left: 10, right: 230, bottom: 300},
- declareSelf:
- 'base
-
- // this needs to be here so the cannonicalCompass knows
- // which view to dirty as part of the redraw.,
- viewclass: 74,
- debug: "clipper2"
- };
- // View clipper2 is declared to ScrollingSample
-
- viewWithPict2 := /* child of clipper2 */
- {viewFlags: 1,
- icon: GetPictAsBits("White World Map", nil),
- viewFormat: 256,
- viewBounds: {left: 0, top: 0, right: 360, bottom: 180},
- viewSetupDoneScript:
- func()
- begin
- // set up the canonicalCompass to scroll this view.
- canonicalCompass.scrolledView := self;
-
- // the canonicalCompass expects dataBounds to be a slot
- // with a bounds frame containing the size of the data that
- // needs to be scrolled. Just use the viewBounds.
- self.dataBounds := viewBounds;
-
- // NOTE: NTK should be setting the viewBounds for this
- // view to match the size of the picture in the resource
- // file. Currently it doesn't, so the viewBounds was
- // just typed in. It would have been possible to use the
- // PictBounds global function (at compile time) to get
- // the size of the picture resource, but I'm lazy.
-
- // NOTE 2: viewOriginX and viewOriginY are supposed to be
- // created and set by the view system, but it's set up to
- // save memory and treat NIL as 0. However, the canonicalCompass
- // doesn't handle that case, so we have to create the
- // viewOriginX and viewOriginY slots ourself and initialize
- // them to 0.
- self.viewOriginX := 0;
- self.viewOriginY := 0;
- end,
- viewclass: 76,
- debug: "viewWithPict2"
- };
- // View viewWithPict2 is declared to ScrollingSample
-
-
-
- canonicalCompass := /* child of clipper2 */
- {
- scrolledView:
- // will be set to the view to be scrolled
- // in the viewWithPict2's viewSetupDoneScript.
-
- nil;,
- _proto: protoTextButton,
- debug: "canonicalCompass"
- };
- // View canonicalCompass is declared to ScrollingSample
-
- // After Script for "canonicalCompass"
- thisView := canonicalCompass;
- thisView._proto := ROM_canonicalcompass;
-
- // this script is called at COMPILE TIME after the view has been compiled
- // It's currently the only way to set the _proto slot with the 1.0b4
- // NTK. The canonicalCompass proto isn't in the NTK library just yet.
-
-
-
-
-
-
-
-
-
- // ---- Beginning of section for non used Layout files ----
-
- // End of output